package ewu

import ewu._

/**
 * ValueRange ist eine KRange mit Werten vom Typ BigInt und dient
 * als Wertebereich fuer Arrays.
 */

case class ValueRange(from: BigInt,
                      to: BigInt,
                      fromE: Expression,
                      toE: Expression)
                        extends KRange[BigInt](from, to) {
  def this(from: Expression, to: Expression) =
    this(0, 0, from, to)

  def this(from: BigInt, to: BigInt) =
    this(from, to, null, null)

  def isInRange(i: BigInt) = (i <= last && i >= first)

  def isEmpty: Boolean = to <= from

  def toScalaRange: Range =
    first.intValue.until(last.intValue)

  override def toString: String = {
    if(from == 0 && to == 0)
      "[" + fromE.toString + ".." + toE.toString + "]"
    else
      "[" + from.toString + ".." + to.toString + "]"
  }
}